package com.tanhua.backmanage.controller;

import com.tanhua.backmanage.service.UserService_xu;
import com.tanhua.backmanage.vo.SummaryVo;
import com.tanhua.backmanage.vo.DistributionVo;
import com.tanhua.dubbo.server.vo.UsersVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("dashboard")
public class UsersController_xu {

    @Autowired
    private UserService_xu userService_xu   ;
    @GetMapping("summary")
    public ResponseEntity<SummaryVo> summary(){
      SummaryVo summaryVo = this.userService_xu.summary();
      if(null!=summaryVo){
          return ResponseEntity.ok(summaryVo);
      }
      return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }

    @GetMapping("users")
    public ResponseEntity<UsersVo> users(@RequestParam("sd")long sd,
                                         @RequestParam("ed")long ed,
                                         @RequestParam("type") String type) {
          UsersVo usersVo = this.userService_xu.users(sd,ed,type);
        if(null!=usersVo){
            return ResponseEntity.ok(usersVo);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
    @GetMapping("distribution")
    public ResponseEntity<DistributionVo> distribution(@RequestParam("sd")long sd,
                                                       @RequestParam("ed")long ed){
        DistributionVo distributionVo = this.userService_xu.distribution(sd,ed);

        if(null!= distributionVo){
            return ResponseEntity.ok(distributionVo);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
